<%--
    Document   : reporteStatus
    Created on : 13/07/2011, 11:03:05 AM
    Author     : electro
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head> 
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <%@taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
        <%@taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
        <%@taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
        <link href="<%=request.getContextPath()%>/css/miestilo.css" rel="stylesheet" type="text/css">
        <link href="<%=request.getContextPath()%>/css/componentes.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery/jquery.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery/jquery.tablesorter.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery/jquery.tablesorter.pager.js"></script>
        <script type="text/javascript" src="<%=request.getContextPath()%>/js/js/Json.js"></script>

        <script type="text/javascript">
            $(document).ready(function(){
                $("#cmbSociedad").change(function(){
                    cargarDivisionPersonal('./AdministradorAction.do');
                    cargarSubDivisionPersonal('./AdministradorAction.do');
                });

                $("#cmbDivPersonal").change(function(){
                    cargarSubDivisionPersonal('./AdministradorAction.do');
                });

                $("#cmbPeriodos").change(function(){
                    cargarEvaluadores('./AdministradorAction.do'),
                    cargarEvaluados('./AdministradorAction.do');
                });
            });

            $(function() {
                $("#tableCalificaciones")
                .tablesorter({
                    widthFixed: true,
                    widgets: ['zebra'],
                    headers: {
                    }
                })
                .tablesorterPager({container: $("#pager"),positionFixed: false});
            });
        </script>
    </head>
    <body>
        <html:form action="AdministradorAction">
            <input type="hidden"  name="method"/>
            <table align="center" border="0" width="900" class="tableToolBar2">
                <tr>
                    <td colspan="5" align="center" class="tituloJsp">
                        Reporte de Calificaciones
                    </td>
                </tr>

                <tr>
                    <td colspan="5">
                        &nbsp;
                    </td>
                </tr>

                <tr>
                    <td align="left" width="100px" class="labelMedium">Sociedad</td>
                    <td align="left" width="190px">
                        <html:select styleId="cmbSociedad" property="idSociedad" styleClass="selectSmall" style="width:165px;">
                            <c:if test="${!empty lstSociedades}">
                                <html:options collection="lstSociedades" property="idSociedad" labelProperty="descripcion"/>
                            </c:if>
                        </html:select>
                    </td>
                    <td>&nbsp;&nbsp;</td>
                    <td align="left" class="labelMedium">Periodo</td>
                    <td align="left">

                        <html:select styleId="cmbPeriodos" property="periodo" styleClass="selectSmall" style="width:80px;">
                            <html:option value="">Todos</html:option>
                            <c:if test="${!empty lstPeriodos}">
                                    <html:options collection="lstPeriodos" property="id" labelProperty="descripcion"/>
                                </c:if>
                        </html:select>
                    </td>
                </tr>

                <tr>
                    <td align="left" class="labelMedium">Div. Personal</td>
                    <td align="left">
                        <html:select styleId="cmbDivPersonal" property="divisionPersonal" styleClass="selectSmall" style="width:165px;">
                            <html:option value="">Todos</html:option>
                            <c:if test="${!empty lstDivisionPersonal}">
                                <html:options collection="lstDivisionPersonal" property="idDivisionPersonal" labelProperty="descripcion"/>
                            </c:if>
                        </html:select>
                    </td>
                    <td>&nbsp;&nbsp;</td>
                    <td align="left" class="labelMedium">Sub Div. Personal</td>
                    <td align="left">
                        <html:select styleId="cmbSubDivPersonal" property="subDivisionPersonal" styleClass="selectSmall">
                            <html:option value="">Todos</html:option>
                        </html:select>
                    </td>
                </tr>

<!--Comentado Los 2 combos Funcionando OK, comentado por el cliente-->
<!--                <tr>-->
<!--                    <td align="left" width="110px" class="labelMedium">Unid. Organizativa</td>-->
<!--                    <td align="left">-->
<!--                        <html:select styleId="cmbUnidadOrganizativa" property="unidadOrganizacional" styleClass="selectSmall" style="width:300px;">-->
<!--                            <html:option value="">Todos</html:option>-->
<!--                                <c:if test="${!empty lstUnidadesOrganizativas}">-->
<!--                                    <html:options collection="lstUnidadesOrganizativas" property="idUnidadOrganizativa" labelProperty="descripcion"/>-->
<!--                                </c:if>-->
<!--                        </html:select>-->
<!--                    </td>-->
<!--                    <td>&nbsp;&nbsp;</td>-->
<!--                    <td align="left" class="labelMedium">Centro de Costo</td>-->
<!--                    <td align="left">-->
<!--                        <html:select styleId="cmbCentroCosto" property="centroCosto" styleClass="selectSmall">-->
<!--                            <html:option value="">Todos</html:option>-->
<!--                            <c:if test="${!empty lstCentroCostos}">-->
<!--                                    <html:options collection="lstCentroCostos" property="idCentroCosto" labelProperty="descripcion"/>-->
<!--                                </c:if>-->
<!--                        </html:select>-->
<!--                    </td>                    -->
<!--                </tr>-->

                <tr>
                    <td align="left" class="labelMedium">Evaluador</td>
                    <td align="left">
                        <html:text property="evaluador"  maxlength="23" style="width:160px;"> </html:text>
<!--                    Combo Funcionando Ok, comentado por el cliente-->
<!--                        <html:select styleId="cmbEvaluador" property="evaluador" styleClass="selectSmall" style="width:300px;">-->
<!--                            <html:option value="">Todos</html:option>-->
<!--                            <c:if test="${!empty lstEvaluadores}">-->
<!--                                    <html:options collection="lstEvaluadores" property="idEvaluador" labelProperty="nombreEvaluador"/>-->
<!--                            </c:if>-->
<!--                        </html:select>-->
                    </td>
                    <td>&nbsp;&nbsp;</td>
                    <td align="left" class="labelMedium">Evaluado</td>
                    <td align="left">
                    <html:text property="evaluado" maxlength="23" style="width:160px;"> </html:text>
<!--                    Combo Funcionando Ok, comentado por el cliente-->                    
<!--                        <html:select styleId="cmbEvaluado" property="evaluado" styleClass="selectSmall" style="width:300px;">-->
<!--                            <html:option value="">Todos</html:option>-->
<!--                            <c:if test="${!empty lstEvaluados}">-->
<!--                                    <html:options collection="lstEvaluados" property="idEmpleado" labelProperty="nombreEmpleado"/>-->
<!--                            </c:if>-->
<!--                        </html:select>-->
                    </td>
                </tr>

 				<tr>
                	<td></td>
                	<td></td>
                	<td></td>
                	<td align="left" class="labelMedium">Tipo de Puesto</td>
                    <td align="left">
                        <html:select styleId="cmbPuestoTipo" property="idTipoPuesto" styleClass="selectSmall" style="width:300px;">
                            <html:option value="">Todos</html:option>
                            <c:if test="${!empty lstTipoPuesto}">
                                <html:options collection="lstTipoPuesto" property="idPuesto" labelProperty="nombrePuesto"/>
                            </c:if>
                        </html:select>
                    </td>
                </tr>
                <tr>
                    <td colspan="2" align="right">
                        <br><button class="button" type= "button" onclick="buscar();"> <img src="images/zoom.png" alt=""  height="15px"/> Buscar</button><br>
                    </td>
                    
                    <td colspan="1" align="center">
                        <br><button class="button" type= "button" onclick="imprimir();"> <img src="images/icono-imprimir-mensaje.gif" alt="" height="15px"/> Imprimir</button><br>
                    </td>
                     <td colspan="2" align="left">
                        <br><button class="buttonExcel"  type= "button" onclick="excel();"> <img src="images/icono-excel.png" alt="" height="15px"/> Exportar a Excel</button><br>
                    </td>
                </tr>

                <tr>
                    <td colspan="5">
                        <HR>
                    </td>
                </tr>
            </table>
                <!-- MUESTRO EL RESULTADO DE LA BUSQUEDA -->
                    <c:if test="${!empty requestScope.lstReportes}">
                        <table cellspacing="0" cellpadding="0" align="center" border="0" class="tableToolBar" width="1200px">
                            <tr bgcolor="#D6E3F2">
                                <td align="right">
                                    <c:if test="${!empty requestScope.lstReportes}">
                                        <div id="pager" class="pager">
                                            <img alt="" src="<%=request.getContextPath()%>/images/jquery_table/first_old_2.png" class="first"/>
                                            <img alt="" src="<%=request.getContextPath()%>/images/jquery_table/prev_old_2.png" class="prev"/>
                                            <input type="text" class="pagedisplay selectSmall" style="text-align: center;width: 30px"/>
                                            <img alt="" src="<%=request.getContextPath()%>/images/jquery_table/next_old_2.png" class="next"/>
                                            <img alt="" src="<%=request.getContextPath()%>/images/jquery_table/last_old_2.png" class="last"/>
                                            <select class="pagesize selectSmall">
                                                <option selected="selected" value="10">10</option>
                                                <option value="20">20</option>
                                                <option  value="30">30</option>
                                            </select>
                                        </div>
                                    </c:if>
                                </td>
                            </tr>
                        </table>

                            <div id="reporteCalificacionesDIV" style="width: 1200px; ">
                                <table id="tableCalificaciones" border="0" width="1200px" class="tablesorter" cellspacing="1">
                                    <thead>
                                        <tr>
                                            <th width="5%"><div align="center">Periodo<br>de<br>Eval.</div></th>
                                            <th width="6%"><div align="center">N°<br>Personal</div></th>
                                            <th ><div align="center">Evaluado</div></th>
                                            <th width="7%"><div align="center">Posición</div></th>
                                            <th width="6%"><div align="center">Grado<br>Salarial</div></th>
                                            <th ><div align="center">Evaluador</div></th>
                                            <th ><div align="center">Posición</div></th>
                                            <th ><div align="center">Área</div></th>
                                            <th width="5%"><div align="center">Calif.<br>Obj.</div></th>
                                            <th width="6%"><div align="center">Calif.<br>Compet.</div></th>
                                            <th width="6%"><div align="center">Eval.<br>Integral</div></th>
                                            <th width="7%"><div align="center">Desc.<br>Integral</div></th>
                                        </tr>
                                    </thead>
                                    <c:forEach var="jbean" items="${lstReportes}">
                                        <tr>
                                            <td><c:out value="${jbean.periodoEvaluado}"/></td>
                                            <td><c:out value="${jbean.nroPersonal}"/></td>
                                            <td><c:out value="${jbean.evaluadoResultado}"/></td>
                                            <td><c:out value="${jbean.posicionEvaluado}"/></td>
                                            <td><c:out value="${jbean.gradoSalarial}"/></td>
                                            <td><c:out value="${jbean.evaluadorResultado}"/></td>
                                            <td><c:out value="${jbean.posicionEvaluador}"/></td>
                                            <td><c:out value="${jbean.area}"/></td>
                                            <td><c:out value="${jbean.calificacionObjetivos}"/></td>
                                            <td><c:out value="${jbean.calificacionCompetencias}"/></td>
                                            <td><c:out value="${jbean.evaluacionIntegral}"/></td>
                                            <td><c:out value="${jbean.descripcionIntegral}"/></td>
                                        </tr>
                                    </c:forEach>
                                </table>
                            </div>
                    </c:if>

                    <c:if test="${empty lstReportes && presionoBuscar == 1}">
                        <div align="center" class="label">NO SE ENCONTRARON REGISTROS</div>
                    </c:if>
           
        </html:form>
        <script type="text/javascript">
            <c:if test="${buscado == true}">
                var sociedad = '<c:out value="${idSociedad}"/>';
                var unidadOrganizativa = '<c:out value="${idUnidadOrganizativa}"/>';
                var divisionPersonal = '<c:out value="${idDivisionPersonal}"/>';
                var subDivisionPersonal = '<c:out value="${idSubDivisionPersonal}"/>';
                var periodo = '<c:out value="${idPeriodo}"/>';
                var evaluador = '<c:out value="${idEvaluador}"/>';
                var evaluado = '<c:out value="${idEvaluado}"/>';
                $(document).ready(function(){
                    cargarUnidadOrganizativa1('./AdministradorAction.do', unidadOrganizativa);
                    cargarDivisionPersonal1('./AdministradorAction.do', sociedad, unidadOrganizativa, divisionPersonal);
                    cargarSubDivisionPersonal1('./AdministradorAction.do', sociedad, unidadOrganizativa, divisionPersonal, subDivisionPersonal);
                    cargarEvaluadores1('./AdministradorAction.do', periodo, evaluador);
                    cargarEvaluados1('./AdministradorAction.do', periodo, evaluado);
                });
            </c:if>

        function retornarHeight(h){
            var posicion_y;
            posicion_y=(screen.height/2)-(h/2);
            return posicion_y;
        }

        function retornarWidth(w){
            var posicion_x;
            posicion_x=(screen.width/2)-(w/2);
            return posicion_x;
        }

        function imprimir(){
            <c:choose>
                <c:when test="${!empty requestScope.lstReportes}">
                    <c:set var="lstReporteCalificaciones" value="${requestScope['lstReportes']}" scope="session" />
                    var url = '<%=request.getContextPath()%>/ImprimirReporteCalificaciones';
                    var opciones="toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, width=800, height=800, top="+retornarHeight(800)+", left="+retornarWidth(800);
                    window.open(url,"",opciones);
                </c:when>
                <c:otherwise>
                    alert("No hay información que mostrar.");
                </c:otherwise>
            </c:choose>
        }

        function excel(){
      	  <c:choose>
	              <c:when test="${!empty requestScope.lstReportes}">
	                  <c:set var="lstReporteCalificaciones" value="${requestScope['lstReportes']}" scope="session" />                    
	                  document.forms[0].method.value='ExcelCalificaciones';
	                  document.forms[0].submit();
	              </c:when>
            <c:otherwise>
                alert("No hay información que mostrar.");
            </c:otherwise>
        	</c:choose>
      	
      }
        
        function buscar(){
            document.forms[0].method.value='buscarRegistroCalificacion';
            document.forms[0].submit();
        }
        </script>
    </body>
</html>
